package com.bwie.parkdemo.mvvm.viewmodel;

import android.app.Application;
import android.databinding.ObservableField;
import android.support.annotation.NonNull;

import com.bwie.lib_core.base.BaseEntity;
import com.bwie.lib_core.mvvm.base.BaseOBViewModel;
import com.bwie.parkdemo.mvvm.model.HistorySignModel;
import com.bwie.parkdemo.mvvm.model.entity.HistorySignEntity;

import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class HistorySignViewModel extends BaseOBViewModel<HistorySignModel> {

    public HistoryClickListener clickListener;
    public ObservableField<List<Object>>datas;

    public HistorySignViewModel(@NonNull Application application) {
        super(application);
        datas = new ObservableField<>();
        clickListener = new HistoryClickListener();
    }

    @Override
    protected HistorySignModel createModel() {
        return new HistorySignModel();
    }

    @Override
    protected void initData() {
        m.requestDaySign().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }

    @Override
    public void onNext(BaseEntity baseEntity) {
        HistorySignEntity entity = (HistorySignEntity) baseEntity;
        datas.set(entity.getDatas());
    }

    public class HistoryClickListener{
        public void selDay(){
            m.requestDaySign().subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(HistorySignViewModel.this);
        }

        public void selMonth(){

        }

    }

}
